#include "Vertex.h"


namespace graphics
{

IDirect3DVertexDeclaration9* V_P::V_Declaration		= 0;
IDirect3DVertexDeclaration9* V_PC::V_Declaration	= 0;
IDirect3DVertexDeclaration9* V_PT::V_Declaration	= 0;
IDirect3DVertexDeclaration9* V_PN::V_Declaration	= 0;

void InitVertexDeclarations(D3DDevice m_Device)
{
	/**********************
	 VERTEX ELEMENTS: V_P
	***********************/
	D3DVERTEXELEMENT9 V_P_Elements[] = 
	{
		//Position
		{0, 0,  D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
		//End of Declaration
		D3DDECL_END()
	};	
	m_Device->CreateVertexDeclaration(V_P_Elements, &V_P::V_Declaration);
	/*=====================================================================================*/

	/**********************
	 VERTEX ELEMENTS: V_PC
	***********************/
	D3DVERTEXELEMENT9 V_PC_Elements[] = 
	{
		//Position
		{0, 0,  D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
		//Color
		{0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0},
		//End of Declaration
		D3DDECL_END()
	};	
	m_Device->CreateVertexDeclaration(V_PC_Elements, &V_PC::V_Declaration);
	/*=====================================================================================*/

	/**********************
	 VERTEX ELEMENTS: V_PT
	***********************/
	D3DVERTEXELEMENT9 V_PT_Elements[] = 
	{
		//Position
		{0, 0,  D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
		//Texture UV
		{0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
		D3DDECL_END()
	};	
	m_Device->CreateVertexDeclaration(V_PT_Elements, &V_PT::V_Declaration);
	/*=====================================================================================*/
	
	/**********************
	 VERTEX ELEMENTS: V_PN
	***********************/
	D3DVERTEXELEMENT9 V_PN_Elements[] = 
	{
		//Position
		{0, 0,  D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
		//Texture UV
		{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
		D3DDECL_END()
	};	
	m_Device->CreateVertexDeclaration(V_PN_Elements, &V_PN::V_Declaration);
	/*=====================================================================================*/
}
void DestroyVertexDeclarations()
{
	SAFE_RELEASE(V_P::V_Declaration)
	SAFE_RELEASE(V_PC::V_Declaration)
	SAFE_RELEASE(V_PT::V_Declaration)
	SAFE_RELEASE(V_PN::V_Declaration)
}

}/* namespace graphics */
